<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <title>有奖竞答 - 社交圈</title>
  <!-- Bootstrap 5 CSS -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
  
  <style>
    body {
      background-color: #f5f5f7;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      color: #1d1d1f;
    }
    
    /* 顶部导航 */
    .top-nav {
      background-color: white;
      padding: 12px 15px;
      position: sticky;
      top: 0;
      z-index: 100;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid #eee;
    }
    
    .nav-title {
      font-size: 18px;
      font-weight: 600;
      margin: 0;
    }
    
    .nav-btn {
      color: #1d1d1f;
      font-size: 20px;
    }
    
    /* 搜索栏 */
    .search-bar {
      padding: 10px 15px;
      background-color: white;
      border-bottom: 1px solid #eee;
    }
    
    .search-input-group {
      position: relative;
    }
    
    .search-input {
      width: 100%;
      padding: 10px 15px 10px 40px;
      border-radius: 8px;
      border: 1px solid #eee;
      background-color: #f5f5f7;
      font-size: 14px;
      outline: none;
    }
    
    .search-icon {
      position: absolute;
      left: 15px;
      top: 50%;
      transform: translateY(-50%);
      color: #8e8e93;
    }
    
    /* 筛选区域 */
    .filter-container {
      background-color: white;
      border-bottom: 1px solid #eee;
      overflow: hidden;
    }
    
    .filter-section {
      padding: 10px 15px;
      border-bottom: 1px solid #eee;
    }
    
    .filter-section:last-child {
      border-bottom: none;
    }
    
    .filter-title {
      font-size: 14px;
      color: #8e8e93;
      margin-bottom: 8px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    
    .filter-clear {
      font-size: 13px;
      color: #007aff;
      cursor: pointer;
    }
    
    /* 标签式筛选 */
    .tag-filter {
      display: flex;
      overflow-x: auto;
      gap: 10px;
      padding-bottom: 5px;
    }
    
    .tag-item {
      white-space: nowrap;
      padding: 6px 14px;
      border-radius: 20px;
      font-size: 14px;
      background-color: #f0f0f0;
      color: #666;
      cursor: pointer;
    }
    
    .tag-item.active {
      background-color: #007aff;
      color: white;
    }
    
    /* 下拉式筛选 */
    .dropdown-filter {
      position: relative;
    }
    
    .dropdown-select {
      width: 100%;
      padding: 10px 15px;
      border-radius: 8px;
      border: 1px solid #eee;
      background-color: #f5f5f7;
      font-size: 14px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      cursor: pointer;
    }
    
    .dropdown-options {
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      background-color: white;
      border-radius: 0 0 8px 8px;
      box-shadow: 0 3px 10px rgba(0,0,0,0.1);
      z-index: 90;
      max-height: 0;
      overflow: hidden;
      transition: max-height 0.3s ease;
    }
    
    .dropdown-options.show {
      max-height: 300px;
      border: 1px solid #eee;
      border-top: none;
    }
    
    .dropdown-option {
      padding: 12px 15px;
      font-size: 14px;
      border-bottom: 1px solid #eee;
      cursor: pointer;
    }
    
    .dropdown-option:last-child {
      border-bottom: none;
    }
    
    .dropdown-option.active {
      background-color: #f0f0f0;
      color: #007aff;
    }
    
    /* 滑块筛选 */
    .slider-filter {
      padding: 10px 0;
    }
    
    .slider-labels {
      display: flex;
      justify-content: space-between;
      font-size: 12px;
      color: #8e8e93;
      margin-bottom: 8px;
    }
    
    .slider {
      width: 100%;
      height: 4px;
      -webkit-appearance: none;
      appearance: none;
      background: #f0f0f0;
      border-radius: 2px;
      outline: none;
    }
    
    .slider::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: #007aff;
      cursor: pointer;
    }
    
    /* 筛选结果统计 */
    .filter-result {
      padding: 10px 15px;
      background-color: white;
      font-size: 14px;
      color: #8e8e93;
      border-bottom: 1px solid #eee;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    
    .result-count {
      color: #1d1d1f;
      font-weight: 600;
    }
    
    .filter-toggle {
      color: #007aff;
      font-size: 14px;
      display: flex;
      align-items: center;
    }
    
    .filter-toggle i {
      margin-left: 5px;
      transition: transform 0.3s ease;
    }
    
    .filter-toggle.collapsed i {
      transform: rotate(180deg);
    }
    
    /* 竞答列表容器 */
    .quiz-list {
      padding: 10px;
    }
    
    /* 竞答卡片 */
    .quiz-card {
      background-color: white;
      border-radius: 12px;
      margin-bottom: 12px;
      overflow: hidden;
      box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    
    /* 竞答头部 */
    .quiz-header {
      padding: 15px 15px 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    
    .quiz-creator {
      display: flex;
      align-items: center;
    }
    
    .creator-avatar {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      object-fit: cover;
      margin-right: 10px;
    }
    
    .creator-name {
      font-weight: 600;
      font-size: 15px;
    }
    
    .quiz-time {
      font-size: 12px;
      color: #8e8e93;
    }
    
    /* 竞答内容 */
    .quiz-content {
      padding: 0 15px 10px;
    }
    
    .quiz-title {
      font-size: 16px;
      font-weight: 600;
      margin-bottom: 8px;
      line-height: 1.4;
    }
    
    .quiz-description {
      font-size: 14px;
      color: #666;
      line-height: 1.5;
      margin-bottom: 12px;
    }
    
    /* 图片容器 */
    .quiz-media {
      width: 100%;
      margin: 0 0 12px;
      border-radius: 8px;
      overflow: hidden;
    }
    
    .quiz-media.single-image img {
      width: 100%;
      height: auto;
      display: block;
    }
    
    .quiz-media.multi-image {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 2px;
    }
    
    .quiz-media.multi-image img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
      aspect-ratio: 1/1;
    }
    
    /* 奖励信息 */
    .reward-info {
      display: flex;
      align-items: center;
      padding: 8px 15px;
      background-color: #fff8e6;
      border-left: 3px solid #ffcc00;
      margin: 0 15px 12px;
      border-radius: 0 4px 4px 0;
    }
    
    .reward-icon {
      color: #ff9500;
      font-size: 18px;
      margin-right: 8px;
    }
    
    .reward-text {
      font-size: 14px;
      font-weight: 600;
      color: #e67e22;
    }
    
    /* 竞答状态 */
    .quiz-status {
      padding: 0 15px 10px;
      display: flex;
      justify-content: space-between;
      font-size: 13px;
      color: #8e8e93;
    }
    
    .status-item {
      display: flex;
      align-items: center;
    }
    
    .status-item i {
      margin-right: 5px;
      font-size: 14px;
    }
    
    /* 底部操作栏 */
    .quiz-actions {
      padding: 10px 15px;
      display: flex;
      justify-content: space-between;
      border-top: 1px solid #eee;
      margin: 0 15px;
    }
    
    .action-btn {
      display: flex;
      align-items: center;
      font-size: 15px;
      padding: 5px 12px;
      border-radius: 20px;
      font-weight: 500;
    }
    
    .action-btn.primary {
      background-color: #007aff;
      color: white;
      border: none;
    }
    
    .action-btn.secondary {
      background-color: #f0f0f0;
      color: #666;
      border: none;
    }
    
    .action-btn i {
      margin-right: 6px;
    }
    
    /* 无图样式特殊处理 */
    .quiz-card.no-image .quiz-content {
      padding-bottom: 15px;
    }
    
    /* 加载更多 */
    .load-more {
      text-align: center;
      padding: 15px;
    }
    
    .load-more-btn {
      background-color: white;
      border: 1px solid #eee;
      border-radius: 20px;
      padding: 8px 20px;
      font-size: 14px;
      color: #666;
    }
    
    .load-more-btn.loading {
      color: #ccc;
    }
    
    /* 空状态 */
    .empty-state {
      padding: 40px 20px;
      text-align: center;
      color: #8e8e93;
    }
    
    .empty-state i {
      font-size: 50px;
      margin-bottom: 15px;
      opacity: 0.5;
    }
    
    .active-filters {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      padding: 8px 15px;
      background-color: #f5f7fa;
      border-bottom: 1px solid #eee;
    }
    
    .active-filter-tag {
      display: flex;
      align-items: center;
      background-color: #e8f0fe;
      color: #007aff;
      padding: 4px 10px;
      border-radius: 12px;
      font-size: 13px;
    }
    
    .active-filter-tag i {
      margin-left: 6px;
      font-size: 12px;
      cursor: pointer;
    }
  </style>
</head>
<body>
  <!-- 顶部导航 -->
  <div class="top-nav">
    <button class="btn btn-link p-0 nav-btn" onclick="history.back()">
      <i class="fa fa-arrow-left"></i>
    </button>
    <h1 class="nav-title">有奖竞答</h1>
    <button class="btn btn-link p-0 nav-btn">
      <i class="fa fa-plus"></i>
    </button>
  </div>
  
  <!-- 搜索栏 -->
  <div class="search-bar">
    <div class="search-input-group">
      <i class="fa fa-search search-icon"></i>
      <input type="text" class="search-input" placeholder="搜索竞答题目、奖励类型...">
    </div>
  </div>
  
  <!-- 已选筛选条件 -->
  <div class="active-filters" id="activeFilters">
    <!-- 动态添加已选筛选条件 -->
  </div>
  
  <!-- 筛选结果统计 -->
  <div class="filter-result">
    <span>找到 <span class="result-count" id="resultCount">12</span> 个竞答</span>
    <div class="filter-toggle" id="filterToggle">
      <span>筛选</span>
      <i class="fa fa-chevron-down"></i>
    </div>
  </div>
  
  <!-- 筛选区域 -->
  <div class="filter-container" id="filterContainer">
    <!-- 奖励类型筛选 -->
    <div class="filter-section">
      <div class="filter-title">
        <span>奖励类型</span>
        <span class="filter-clear" data-section="reward">清除</span>
      </div>
      <div class="tag-filter" data-type="reward">
        <div class="tag-item active" data-value="all">全部</div>
        <div class="tag-item" data-value="cash">现金奖励</div>
        <div class="tag-item" data-value="physical">实物奖品</div>
        <div class="tag-item" data-value="coupon">优惠券</div>
        <div class="tag-item" data-value="virtual">虚拟物品</div>
      </div>
    </div>
    
    <!-- 状态筛选 -->
    <div class="filter-section">
      <div class="filter-title">
        <span>竞答状态</span>
        <span class="filter-clear" data-section="status">清除</span>
      </div>
      <div class="tag-filter" data-type="status">
        <div class="tag-item active" data-value="all">全部</div>
        <div class="tag-item" data-value="ongoing">进行中</div>
        <div class="tag-item" data-value="upcoming">即将开始</div>
        <div class="tag-item" data-value="ending">即将结束</div>
        <div class="tag-item" data-value="ended">已结束</div>
      </div>
    </div>
    
    <!-- 参与人数筛选 -->
    <div class="filter-section">
      <div class="filter-title">
        <span>参与人数</span>
        <span class="filter-clear" data-section="participants">清除</span>
      </div>
      <div class="dropdown-filter" data-type="participants">
        <div class="dropdown-select">
          <span>全部人数</span>
          <i class="fa fa-chevron-down"></i>
        </div>
        <div class="dropdown-options">
          <div class="dropdown-option active" data-value="all">全部人数</div>
          <div class="dropdown-option" data-value="0-100">100人以下</div>
          <div class="dropdown-option" data-value="100-500">100-500人</div>
          <div class="dropdown-option" data-value="500-1000">500-1000人</div>
          <div class="dropdown-option" data-value="1000+">1000人以上</div>
        </div>
      </div>
    </div>
    
    <!-- 剩余时间筛选 -->
    <div class="filter-section">
      <div class="filter-title">
        <span>剩余时间</span>
        <span class="filter-clear" data-section="time">清除</span>
      </div>
      <div class="dropdown-filter" data-type="time">
        <div class="dropdown-select">
          <span>全部时间</span>
          <i class="fa fa-chevron-down"></i>
        </div>
        <div class="dropdown-options">
          <div class="dropdown-option active" data-value="all">全部时间</div>
          <div class="dropdown-option" data-value="1h">1小时内</div>
          <div class="dropdown-option" data-value="1d">1天内</div>
          <div class="dropdown-option" data-value="3d">3天内</div>
          <div class="dropdown-option" data-value="7d+">7天以上</div>
        </div>
      </div>
    </div>
    
    <!-- 奖励价值筛选 -->
    <div class="filter-section">
      <div class="filter-title">
        <span>奖励价值范围 (¥)</span>
        <span class="filter-clear" data-section="value">清除</span>
      </div>
      <div class="slider-filter" data-type="value">
        <div class="slider-labels">
          <span>0</span>
          <span id="sliderValue">500</span>
          <span>1000+</span>
        </div>
        <input type="range" min="0" max="1000" value="500" class="slider" id="valueSlider">
      </div>
    </div>
  </div>
  
  <!-- 竞答列表 -->
  <div class="quiz-list" id="quizList">
    <!-- 多图竞答 -->
    <div class="quiz-card" data-reward="physical" data-status="ongoing" data-participants="1000+" data-time="1d" data-value="200">
      <div class="quiz-header">
        <div class="quiz-creator">
          <img src="https://picsum.photos/100/100?random=1" alt="发起者头像" class="creator-avatar">
          <div>
            <div class="creator-name">知识竞赛官方</div>
            <div class="quiz-time">2小时前</div>
          </div>
        </div>
      </div>
      
      <div class="quiz-content">
        <div class="quiz-title">猜一猜这三张图片分别是哪个国家的标志性建筑？</div>
        <div class="quiz-description">
          仔细观察图片中的建筑特征，回答出每个建筑所属的国家，全部答对即可参与抽奖，有机会获得精美旅行套装！
        </div>
        
        <div class="quiz-media multi-image">
          <img src="https://picsum.photos/300/300?random=10" alt="竞答图片1">
          <img src="https://picsum.photos/300/300?random=11" alt="竞答图片2">
          <img src="https://picsum.photos/300/300?random=12" alt="竞答图片3">
        </div>
        
        <div class="reward-info">
          <i class="fa fa-gift reward-icon"></i>
          <div class="reward-text">奖励：旅行套装 × 10份</div>
        </div>
        
        <div class="quiz-status">
          <div class="status-item">
            <i class="fa fa-user"></i>
            <span>1,258人参与</span>
          </div>
          <div class="status-item">
            <i class="fa fa-clock-o"></i>
            <span>剩余12小时</span>
          </div>
        </div>
      </div>
      
      <div class="quiz-actions">
        <button class="action-btn secondary">
          <i class="fa fa-share-alt"></i>
          <span>分享</span>
        </button>
        <button class="action-btn primary">
          <i class="fa fa-pencil"></i>
          <span>立即参与</span>
        </button>
      </div>
    </div>
    
    <!-- 单图竞答 -->
    <div class="quiz-card" data-reward="coupon" data-status="ongoing" data-participants="1000+" data-time="3d" data-value="50">
      <div class="quiz-header">
        <div class="quiz-creator">
          <img src="https://picsum.photos/100/100?random=2" alt="发起者头像" class="creator-avatar">
          <div>
            <div class="creator-name">美食达人</div>
            <div class="quiz-time">5小时前</div>
          </div>
        </div>
      </div>
      
      <div class="quiz-content">
        <div class="quiz-title">这道菜的主要食材是什么？</div>
        <div class="quiz-description">
          这是一道经典的地方特色菜，猜一猜它的主要食材是什么？答对者有机会获得50元餐饮代金券！
        </div>
        
        <div class="quiz-media single-image">
          <img src="https://picsum.photos/600/400?random=20" alt="竞答图片">
        </div>
        
        <div class="reward-info">
          <i class="fa fa-ticket reward-icon"></i>
          <div class="reward-text">奖励：50元餐饮代金券 × 50份</div>
        </div>
        
        <div class="quiz-status">
          <div class="status-item">
            <i class="fa fa-user"></i>
            <span>3,742人参与</span>
          </div>
          <div class="status-item">
            <i class="fa fa-clock-o"></i>
            <span>剩余3天</span>
          </div>
        </div>
      </div>
      
      <div class="quiz-actions">
        <button class="action-btn secondary">
          <i class="fa fa-share-alt"></i>
          <span>分享</span>
        </button>
        <button class="action-btn primary">
          <i class="fa fa-pencil"></i>
          <span>立即参与</span>
        </button>
      </div>
    </div>
    
    <!-- 无图竞答 -->
    <div class="quiz-card no-image" data-reward="cash" data-status="ongoing" data-participants="1000+" data-time="1d" data-value="100">
      <div class="quiz-header">
        <div class="quiz-creator">
          <img src="https://picsum.photos/100/100?random=3" alt="发起者头像" class="creator-avatar">
          <div>
            <div class="creator-name">科学小知识</div>
            <div class="quiz-time">昨天 18:30</div>
          </div>
        </div>
      </div>
      
      <div class="quiz-content">
        <div class="quiz-title">下列哪种行星不属于类地行星？</div>
        <div class="quiz-description">
          太阳系中有多颗行星，其中类地行星具有相似的结构特征。请从以下选项中选出不属于类地行星的选项：
          <br>
          A. 水星 &nbsp;&nbsp; B. 金星 &nbsp;&nbsp; C. 火星 &nbsp;&nbsp; D. 木星
        </div>
        
        <div class="reward-info">
          <i class="fa fa-money reward-icon"></i>
          <div class="reward-text">奖励：现金红包 1-100元随机</div>
        </div>
        
        <div class="quiz-status">
          <div class="status-item">
            <i class="fa fa-user"></i>
            <span>5,219人参与</span>
          </div>
          <div class="status-item">
            <i class="fa fa-clock-o"></i>
            <span>剩余1天</span>
          </div>
        </div>
      </div>
      
      <div class="quiz-actions">
        <button class="action-btn secondary">
          <i class="fa fa-share-alt"></i>
          <span>分享</span>
        </button>
        <button class="action-btn primary">
          <i class="fa fa-pencil"></i>
          <span>立即参与</span>
        </button>
      </div>
    </div>
    
    <!-- 多图竞答 -->
    <div class="quiz-card" data-reward="virtual" data-status="ending" data-participants="500-1000" data-time="1h" data-value="80">
      <div class="quiz-header">
        <div class="quiz-creator">
          <img src="https://picsum.photos/100/100?random=4" alt="发起者头像" class="creator-avatar">
          <div>
            <div class="creator-name">电影爱好者</div>
            <div class="quiz-time">昨天 10:15</div>
          </div>
        </div>
      </div>
      
      <div class="quiz-content">
        <div class="quiz-title">这两张截图来自哪两部电影？</div>
        <div class="quiz-description">
          以下是两部经典电影的截图，说出它们的片名即可参与抽奖，正确回答者有机会获得电影通兑券2张。
        </div>
        
        <div class="quiz-media multi-image">
          <img src="https://picsum.photos/300/300?random=30" alt="竞答图片1">
          <img src="https://picsum.photos/300/300?random=31" alt="竞答图片2">
          <div style="background-color: #f9f9f9;"></div>
        </div>
        
        <div class="reward-info">
          <i class="fa fa-film reward-icon"></i>
          <div class="reward-text">奖励：电影通兑券 × 20份</div>
        </div>
        
        <div class="quiz-status">
          <div class="status-item">
            <i class="fa fa-user"></i>
            <span>845人参与</span>
          </div>
          <div class="status-item">
            <i class="fa fa-clock-o"></i>
            <span>剩余45分钟</span>
          </div>
        </div>
      </div>
      
      <div class="quiz-actions">
        <button class="action-btn secondary">
          <i class="fa fa-share-alt"></i>
          <span>分享</span>
        </button>
        <button class="action-btn primary">
          <i class="fa fa-pencil"></i>
          <span>立即参与</span>
        </button>
      </div>
    </div>
  </div>
  
  <!-- 加载更多 -->
  <div class="load-more">
    <button class="load-more-btn" id="loadMoreBtn">
      <i class="fa fa-refresh"></i> 加载更多
    </button>
  </div>

  <!-- Bootstrap JS -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  
  <script>
    // 筛选条件状态管理
    const filterState = {
      reward: 'all',
      status: 'all',
      participants: 'all',
      time: 'all',
      value: 500
    };
    
    // 筛选面板展开/折叠
    const filterToggle = document.getElementById('filterToggle');
    const filterContainer = document.getElementById('filterContainer');
    
    filterToggle.addEventListener('click', function() {
      this.classList.toggle('collapsed');
      if (this.classList.contains('collapsed')) {
        filterContainer.style.maxHeight = '0';
        filterContainer.style.overflow = 'hidden';
      } else {
        filterContainer.style.maxHeight = filterContainer.scrollHeight + 'px';
        filterContainer.style.overflow = 'visible';
      }
    });
    
    // 初始化筛选面板为折叠状态
    filterToggle.click();
    
    // 标签式筛选
    document.querySelectorAll('.tag-filter .tag-item').forEach(item => {
      item.addEventListener('click', function() {
        const filterType = this.closest('.tag-filter').getAttribute('data-type');
        const filterValue = this.getAttribute('data-value');
        
        // 更新当前筛选组的选中状态
        this.closest('.tag-filter').querySelectorAll('.tag-item').forEach(i => {
          i.classList.remove('active');
        });
        this.classList.add('active');
        
        // 更新筛选状态
        filterState[filterType] = filterValue;
        
        // 应用筛选
        applyFilters();
        
        // 更新活跃筛选标签
        updateActiveFilterTags();
      });
    });
    
    // 下拉式筛选
    document.querySelectorAll('.dropdown-select').forEach(select => {
      select.addEventListener('click', function() {
        const options = this.nextElementSibling;
        options.classList.toggle('show');
      });
    });
    
    document.querySelectorAll('.dropdown-option').forEach(option => {
      option.addEventListener('click', function() {
        const filterType = this.closest('.dropdown-filter').getAttribute('data-type');
        const filterValue = this.getAttribute('data-value');
        const selectText = this.textContent;
        
        // 更新当前筛选组的选中状态
        this.closest('.dropdown-options').querySelectorAll('.dropdown-option').forEach(opt => {
          opt.classList.remove('active');
        });
        this.classList.add('active');
        
        // 更新下拉框显示文本
        this.closest('.dropdown-options').previousElementSibling.querySelector('span').textContent = selectText;
        
        // 关闭下拉框
        this.closest('.dropdown-options').classList.remove('show');
        
        // 更新筛选状态
        filterState[filterType] = filterValue;
        
        // 应用筛选
        applyFilters();
        
        // 更新活跃筛选标签
        updateActiveFilterTags();
      });
    });
    
    // 滑块筛选
    const valueSlider = document.getElementById('valueSlider');
    const sliderValue = document.getElementById('sliderValue');
    
    valueSlider.addEventListener('input', function() {
      const value = this.value;
      sliderValue.textContent = value >= 1000 ? '1000+' : value;
      
      // 更新筛选状态
      filterState.value = parseInt(value);
      
      // 应用筛选
      applyFilters();
      
      // 更新活跃筛选标签
      updateActiveFilterTags();
    });
    
    // 清除筛选条件
    document.querySelectorAll('.filter-clear').forEach(clearBtn => {
      clearBtn.addEventListener('click', function() {
        const section = this.getAttribute('data-section');
        resetFilterSection(section);
      });
    });
    
    // 重置筛选区域
    function resetFilterSection(section) {
      // 重置标签式筛选
      const tagFilter = document.querySelector(`.tag-filter[data-type="${section}"]`);
      if (tagFilter) {
        const allItem = tagFilter.querySelector('.tag-item[data-value="all"]');
        if (allItem && !allItem.classList.contains('active')) {
          allItem.click();
        }
        return;
      }
      
      // 重置下拉式筛选
      const dropdownFilter = document.querySelector(`.dropdown-filter[data-type="${section}"]`);
      if (dropdownFilter) {
        const allOption = dropdownFilter.querySelector('.dropdown-option[data-value="all"]');
        if (allOption && !allOption.classList.contains('active')) {
          allOption.click();
        }
        return;
      }
      
      // 重置滑块筛选
      if (section === 'value') {
        valueSlider.value = 500;
        sliderValue.textContent = 500;
        filterState.value = 500;
        applyFilters();
        updateActiveFilterTags();
      }
    }
    
    // 应用所有筛选条件
    function applyFilters() {
      const quizCards = document.querySelectorAll('.quiz-card');
      let visibleCount = 0;
      
      quizCards.forEach(card => {
        let isVisible = true;
        
        // 奖励类型筛选
        if (filterState.reward !== 'all' && card.getAttribute('data-reward') !== filterState.reward) {
          isVisible = false;
        }
        
        // 状态筛选
        if (filterState.status !== 'all' && card.getAttribute('data-status') !== filterState.status) {
          isVisible = false;
        }
        
        // 参与人数筛选
        if (filterState.participants !== 'all') {
          const cardParticipants = card.getAttribute('data-participants');
          if (cardParticipants !== filterState.participants) {
            isVisible = false;
          }
        }
        
        // 剩余时间筛选
        if (filterState.time !== 'all') {
          const cardTime = card.getAttribute('data-time');
          if (cardTime !== filterState.time) {
            isVisible = false;
          }
        }
        
        // 奖励价值筛选
        const cardValue = parseInt(card.getAttribute('data-value'));
        if (cardValue > filterState.value) {
          isVisible = false;
        }
        
        // 显示或隐藏卡片
        card.style.display = isVisible ? 'block' : 'none';
        if (isVisible) visibleCount++;
      });
      
      // 更新结果计数
      document.getElementById('resultCount').textContent = visibleCount;
    }
    
    // 筛选标签文本映射
    const filterLabelMap = {
      reward: {
        'all': '全部奖励',
        'cash': '现金奖励',
        'physical': '实物奖品',
        'coupon': '优惠券',
        'virtual': '虚拟物品'
      },
      status: {
        'all': '全部状态',
        'ongoing': '进行中',
        'upcoming': '即将开始',
        'ending': '即将结束',
        'ended': '已结束'
      },
      participants: {
        'all': '全部人数',
        '0-100': '100人以下',
        '100-500': '100-500人',
        '500-1000': '500-1000人',
        '1000+': '1000人以上'
      },
      time: {
        'all': '全部时间',
        '1h': '1小时内',
        '1d': '1天内',
        '3d': '3天内',
        '7d+': '7天以上'
      },
      value: (value) => `奖励价值 ≤ ¥${value >= 1000 ? '1000+' : value}`
    };
    
    // 更新活跃筛选标签
    function updateActiveFilterTags() {
      const activeFiltersContainer = document.getElementById('activeFilters');
      activeFiltersContainer.innerHTML = '';
      
      // 检查是否有活跃筛选条件
      let hasActiveFilters = false;
      
      // 添加活跃筛选标签
      Object.keys(filterState).forEach(type => {
        const value = filterState[type];
        
        // 跳过"全部"或默认值
        if ((type === 'reward' || type === 'status' || type === 'participants' || type === 'time') && value === 'all') {
          return;
        }
        if (type === 'value' && value === 500) {
          return;
        }
        
        hasActiveFilters = true;
        
        // 创建标签
        const tag = document.createElement('div');
        tag.className = 'active-filter-tag';
        tag.setAttribute('data-type', type);
        
        // 设置标签文本
        if (type === 'value') {
          tag.innerHTML = `${filterLabelMap[type](value)} <i class="fa fa-times"></i>`;
        } else {
          tag.innerHTML = `${filterLabelMap[type][value]} <i class="fa fa-times"></i>`;
        }
        
        // 绑定删除事件
        tag.querySelector('i').addEventListener('click', function() {
          resetFilterSection(type);
        });
        
        activeFiltersContainer.appendChild(tag);
      });
      
      // 隐藏/显示活跃筛选容器
      activeFiltersContainer.style.display = hasActiveFilters ? 'flex' : 'none';
    }
    
    // 搜索功能
    document.querySelector('.search-input').addEventListener('input', function() {
      const searchTerm = this.value.toLowerCase().trim();
      const quizCards = document.querySelectorAll('.quiz-card');
      let visibleCount = 0;
      
      quizCards.forEach(card => {
        // 只搜索当前可见的卡片
        if (card.style.display === 'none') return;
        
        const title = card.querySelector('.quiz-title').textContent.toLowerCase();
        const description = card.querySelector('.quiz-description')?.textContent.toLowerCase() || '';
        const reward = card.querySelector('.reward-text').textContent.toLowerCase();
        
        const matchesSearch = title.includes(searchTerm) || description.includes(searchTerm) || reward.includes(searchTerm);
        
        card.style.display = matchesSearch ? 'block' : 'none';
        if (matchesSearch) visibleCount++;
      });
      
      // 更新结果计数
      document.getElementById('resultCount').textContent = visibleCount;
    });
    
    // 立即参与按钮
    document.querySelectorAll('.action-btn.primary').forEach(btn => {
      btn.addEventListener('click', function() {
        const quizTitle = this.closest('.quiz-card').querySelector('.quiz-title').textContent;
        alert(`即将参与：${quizTitle}\n(实际应用中这里会跳转到答题页面)`);
      });
    });
    
    // 分享按钮
    document.querySelectorAll('.action-btn.secondary').forEach(btn => {
      btn.addEventListener('click', function() {
        alert('分享到：微信好友、朋友圈、微博、QQ好友');
      });
    });
    
    // 新建竞答按钮
    document.querySelector('.top-nav .fa-plus').parentElement.addEventListener('click', function() {
      alert('创建新的有奖竞答');
    });
    
    // 加载更多功能
    document.getElementById('loadMoreBtn').addEventListener('click', function() {
      const btn = this;
      btn.classList.add('loading');
      btn.innerHTML = '<i class="fa fa-spinner fa-spin"></i> 加载中...';
      
      // 模拟加载延迟
      setTimeout(() => {
        const quizList = document.getElementById('quizList');
        
        // 随机添加新的竞答卡片
        const randomType = Math.floor(Math.random() * 3);
        const rewardTypes = ['cash', 'physical', 'coupon', 'virtual'];
        const statusTypes = ['ongoing', 'ending', 'upcoming'];
        const participantRanges = ['0-100', '100-500', '500-1000', '1000+'];
        const timeRanges = ['1h', '1d', '3d', '7d+'];
        const randomValue = Math.floor(Math.random() * 1000);
        
        let newQuiz;
        
        if (randomType === 0) {
          // 多图类型
          newQuiz = `
            <div class="quiz-card" 
                 data-reward="${rewardTypes[Math.floor(Math.random() * rewardTypes.length)]}"
                 data-status="${statusTypes[Math.floor(Math.random() * statusTypes.length)]}"
                 data-participants="${participantRanges[Math.floor(Math.random() * participantRanges.length)]}"
                 data-time="${timeRanges[Math.floor(Math.random() * timeRanges.length)]}"
                 data-value="${randomValue}">
              <div class="quiz-header">
                <div class="quiz-creator">
                  <img src="https://picsum.photos/100/100?random=${Math.random()*100}" alt="发起者头像" class="creator-avatar">
                  <div>
                    <div class="creator-name">旅行爱好者</div>
                    <div class="quiz-time">3小时前</div>
                  </div>
                </div>
              </div>
              
              <div class="quiz-content">
                <div class="quiz-title">这些风景照片拍摄于哪个国家？</div>
                <div class="quiz-description">
                  这组照片展示了某个国家的自然风光，猜出正确国家即可参与抽奖，有机会获得精美纪念品。
                </div>
                
                <div class="quiz-media multi-image">
                  <img src="https://picsum.photos/300/300?random=${Math.random()*100}" alt="竞答图片1">
                  <img src="https://picsum.photos/300/300?random=${Math.random()*100}" alt="竞答图片2">
                  <img src="https://picsum.photos/300/300?random=${Math.random()*100}" alt="竞答图片3">
                </div>
                
                <div class="reward-info">
                  <i class="fa fa-gift reward-icon"></i>
                  <div class="reward-text">奖励：精美纪念品 × 30份</div>
                </div>
                
                <div class="quiz-status">
                  <div class="status-item">
                    <i class="fa fa-user"></i>
                    <span>${Math.floor(Math.random()*5000)+1000}人参与</span>
                  </div>
                  <div class="status-item">
                    <i class="fa fa-clock-o"></i>
                    <span>剩余${Math.floor(Math.random()*5)+1}天</span>
                  </div>
                </div>
              </div>
              
              <div class="quiz-actions">
                <button class="action-btn secondary">
                  <i class="fa fa-share-alt"></i>
                  <span>分享</span>
                </button>
                <button class="action-btn primary">
                  <i class="fa fa-pencil"></i>
                  <span>立即参与</span>
                </button>
              </div>
            </div>
          `;
        } else if (randomType === 1) {
          // 单图类型
          newQuiz = `
            <div class="quiz-card"
                 data-reward="${rewardTypes[Math.floor(Math.random() * rewardTypes.length)]}"
                 data-status="${statusTypes[Math.floor(Math.random() * statusTypes.length)]}"
                 data-participants="${participantRanges[Math.floor(Math.random() * participantRanges.length)]}"
                 data-time="${timeRanges[Math.floor(Math.random() * timeRanges.length)]}"
                 data-value="${randomValue}">
              <div class="quiz-header">
                <div class="quiz-creator">
                  <img src="https://picsum.photos/100/100?random=${Math.random()*100}" alt="发起者头像" class="creator-avatar">
                  <div>
                    <div class="creator-name">音乐达人</div>
                    <div class="quiz-time">6小时前</div>
                  </div>
                </div>
              </div>
              
              <div class="quiz-content">
                <div class="quiz-title">这位歌手的名字是什么？</div>
                <div class="quiz-description">
                  图中是一位著名歌手的演出照，猜出他/她的名字即可参与抽奖，有机会获得最新专辑一张。
                </div>
                
                <div class="quiz-media single-image">
                  <img src="https://picsum.photos/600/400?random=${Math.random()*100}" alt="竞答图片">
                </div>
                
                <div class="reward-info">
                  <i class="fa fa-music reward-icon"></i>
                  <div class="reward-text">奖励：最新专辑 × 15份</div>
                </div>
                
                <div class="quiz-status">
                  <div class="status-item">
                    <i class="fa fa-user"></i>
                    <span>${Math.floor(Math.random()*5000)+1000}人参与</span>
                  </div>
                  <div class="status-item">
                    <i class="fa fa-clock-o"></i>
                    <span>剩余${Math.floor(Math.random()*5)+1}天</span>
                  </div>
                </div>
              </div>
              
              <div class="quiz-actions">
                <button class="action-btn secondary">
                  <i class="fa fa-share-alt"></i>
                  <span>分享</span>
                </button>
                <button class="action-btn primary">
                  <i class="fa fa-pencil"></i>
                  <span>立即参与</span>
                </button>
              </div>
            </div>
          `;
        } else {
          // 无图类型
          newQuiz = `
            <div class="quiz-card no-image"
                 data-reward="${rewardTypes[Math.floor(Math.random() * rewardTypes.length)]}"
                 data-status="${statusTypes[Math.floor(Math.random() * statusTypes.length)]}"
                 data-participants="${participantRanges[Math.floor(Math.random() * participantRanges.length)]}"
                 data-time="${timeRanges[Math.floor(Math.random() * timeRanges.length)]}"
                 data-value="${randomValue}">
              <div class="quiz-header">
                <div class="quiz-creator">
                  <img src="https://picsum.photos/100/100?random=${Math.random()*100}" alt="发起者头像" class="creator-avatar">
                  <div>
                    <div class="creator-name">历史小课堂</div>
                    <div class="quiz-time">昨天 09:45</div>
                  </div>
                </div>
              </div>
              
              <div class="quiz-content">
                <div class="quiz-title">中国历史上哪个朝代持续时间最长？</div>
                <div class="quiz-description">
                  中国有着悠久的历史，经历了多个朝代的更替。请从以下选项中选出持续时间最长的朝代：
                  <br>
                  A. 汉朝 &nbsp;&nbsp; B. 唐朝 &nbsp;&nbsp; C. 明朝 &nbsp;&nbsp; D. 清朝
                </div>
                
                <div class="reward-info">
                  <i class="fa fa-book reward-icon"></i>
                  <div class="reward-text">奖励：历史百科全书 × 5份</div>
                </div>
                
                <div class="quiz-status">
                  <div class="status-item">
                    <i class="fa fa-user"></i>
                    <span>${Math.floor(Math.random()*5000)+1000}人参与</span>
                  </div>
                  <div class="status-item">
                    <i class="fa fa-clock-o"></i>
                    <span>剩余${Math.floor(Math.random()*5)+1}天</span>
                  </div>
                </div>
              </div>
              
              <div class="quiz-actions">
                <button class="action-btn secondary">
                  <i class="fa fa-share-alt"></i>
                  <span>分享</span>
                </button>
                <button class="action-btn primary">
                  <i class="fa fa-pencil"></i>
                  <span>立即参与</span>
                </button>
              </div>
            </div>
          `;
        }
        
        // 添加到列表
        quizList.insertAdjacentHTML('beforeend', newQuiz);
        
        // 应用当前筛选条件到新添加的卡片
        applyFilters();
        
        // 恢复按钮状态
        btn.classList.remove('loading');
        btn.innerHTML = '<i class="fa fa-refresh"></i> 加载更多';
        
        // 为新添加的按钮绑定事件
        bindNewQuizEvents();
      }, 1500);
    });
    
    // 为新添加的竞答卡片绑定事件
    function bindNewQuizEvents() {
      const lastCard = document.querySelector('.quiz-card:last-child');
      
      // 立即参与按钮
      lastCard.querySelector('.action-btn.primary').addEventListener('click', function() {
        const quizTitle = this.closest('.quiz-card').querySelector('.quiz-title').textContent;
        alert(`即将参与：${quizTitle}\n(实际应用中这里会跳转到答题页面)`);
      });
      
      // 分享按钮
      lastCard.querySelector('.action-btn.secondary').addEventListener('click', function() {
        alert('分享到：微信好友、朋友圈、微博、QQ好友');
      });
    }
  </script>
</body>
</html>
